package evolution.statistics;

import evolution.individual.Individual;
import evolution.individual.IndividualSorter;

public class PopulationStatistics {
	private Individual best;
	private Individual median;

	public Individual getBest() {
		return best;
	}

	public void setBest(Individual best) {
		this.best = best;
	}

	public Individual getMedian() {
		return median;
	}

	public void setMedian(Individual median) {
		this.median = median;
	}

	/**
	 * @param population
	 *            (will be sorted)
	 * @return
	 */
	public static PopulationStatistics create(Individual[] population) {
		IndividualSorter.sort(population);

		PopulationStatistics populationStatistics = new PopulationStatistics();

		populationStatistics.setBest(population[0]);

		int median = population.length / 2;
		populationStatistics.setMedian(population[median]);
		return populationStatistics;
	}
}
